<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_work" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="batchSetupTimeSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/mes/produce/flow/ProducePlanDetailed?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 设置时间 </span>
      </div>
      <el-table :data="s_work">
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="步骤" prop="workName">
        </el-table-column>
        <el-table-column label="人员" prop="assigned_id">
          <template slot-scope="scope">
            {{scope.row.assigned_id}}
            <el-button @click="popSelectionOfficerCurrency('assigned_id','assigned_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
          </template>
        </el-table-column>
        <el-table-column label="时长" prop="duration">
          <template slot-scope="scope">
            <el-input v-model="scope.row.duration" />
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="SelectionOfficerCurrencyVisible" append-to-body>
      <SelectionOfficerCurrency v-if="SelectionOfficerCurrencyVisible" ref="SelectionOfficerCurrency" :popparams="popparams"> </SelectionOfficerCurrency>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectionOfficerCurrency from "@/views/mes/autooffice/SelectionOfficerCurrency";
  export default {
    name: 'BatchSetupTime',
    components: {
      SelectionOfficerCurrency,
    },
    props: ['popparams'],
    data() {
      return {
        SelectionOfficerCurrencyVisible: false,
        SelectionOfficerCurrencyValue: null,
        SelectionOfficerCurrencyDesc: null,
        vueparams: this.getVUEParams(""),
        s_work: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/batchSetupTime?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      batchSetupTimeSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/batchSetupTimeSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/produce/flow/ProducePlanDetailed/producePlanDetailed?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      u_pro_time(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/u_pro_time?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popSelectionOfficerCurrency(desc, value) {
        this.SelectionOfficerCurrencyVisible = true;
        this.SelectionOfficerCurrencyDesc = desc;
        this.SelectionOfficerCurrencyValue = value;
      },
      closeSelectionOfficerCurrency(value, desc) {
        this.SelectionOfficerCurrencyVisible = false;
        this.$set(this.s_work, this.SelectionOfficerCurrencyDesc, desc);
        this.$set(this.s_work, this.SelectionOfficerCurrencyValue, value);
      },
    },
  }
</script>
